from redis.cluster import RedisCluster
from redis import Redis

redis_cluster = {
    "4000": "10.12.240.134",
    "4010": "10.16.240.134",
    "4020": "10.15.240.134",
    "4030": "10.32.240.134",
    "4050": "10.45.240.134",
    "4060": "10.44.240.134",
    "4070": "10.46.240.134",
    "4080": "10.71.240.134",
    "4090": "10.72.240.134",
    "beta-08": "10.63.4.134",
    "sit_union": "10.141.194.134",
}

redis = {
    "beta-06-zone": "10.63.102.163",
    "beta-08-zone": "10.63.104.124",
    "sit_zone": "10.141.194.163",
}

host = "beta-08"
# print(redis_cluster[host])
redis_cluster_cli = RedisCluster(redis_cluster[host], port=26379, password='viuRDS2793')
# print(redis_cluster_cli.ping())


host2 = "beta-08-zone"
# print(redis[host2])
redis_cli = Redis(redis[host2], port=26379, password='viuRDS2793')
# print(redis_cli.ping())



def scan():
    lst = list()
    for key in redis_cluster_cli.scan_iter(match="event_vm_collection_*", count=20000):
        lst.append(key)
    print(lst)


def get():
    # print(redis_cli.get("cgboss_4616_psMove_ins-3z0t09mxgl1k5fiunznvpbqy2d1tom8f"))
    # print(redis_cli.zrange("2_game_pool_keys", 0, -1))
    # print(redis_cluster_cli.get("cgboss_4868_psMove_sItemId2Terminated_66155074086240771"))
    # print(redis_cluster_cli.get("cgboss-is_phone_vm_bloom"))
    print(redis_cluster_cli.exists("202_agent_and_service_upgrade_active_operation_set"))


def delete():
    # print(redis_cluster_cli.delete("traffic_report_1_1"))
    redis_cluster_cli.delete("807_2280")

def main():
    # scan()
    # delete()
    get()

main()